function WrapText($width = 74, $indent = 8) {

	begin {
						    $indent = new-object string ' ', $indent
		                $whitespace = "`t`r`n ".ToCharArray()
		[Text.StringBuilder]$output = $indent
		          $currentLineWidth = 0
	}

	process {
		if([string]::IsNullOrEmpty($_)) {
			return
		}
		
		$words = $_.Split($whitespace, [StringSplitOptions]::RemoveEmptyEntries)
		
		$index = 0
		$count = 0
		
		while(($index + $count) -lt $words.Length) {
		
			while($currentLineWidth -le $width) {
				$w = $words[$index + $count].Length + 1;
				
				if(($currentLineWidth + $w) -gt $width) {
					break
				}
				
				$currentLineWidth += $w
				$count++
			}
			
			if($count -gt 0) {
				$words[$index..($index + $count - 1)] |% {
					$output.Append($_)  | out-null
					$output.Append(' ') | out-null
				}
				
				$output.AppendLine() | out-null
				$output.Append($indent) | out-null
			}
			else {
				$word = $words[$index]
				$line = $null;
				
				do {
					if($word.Length -gt $width) {
						$line = $word.Substring(0, $width)
						$word = $word.Substring($width)
					}
					else {
						$line = $word;
						$word = $null;
					}
					
					$output.AppendLine($indent + $line) | out-null
				} while($word)
				
				$count++
			}
		
			$index += $count

			$count = 0
			$currentLineWidth = 0
		}
	}

	end {
		$output.ToString()
	}
}

Add-PSSnapin Pscx -ea SilentlyContinue
Add-PSSnapin PscxDeveloper -ea SilentlyContinue

Get-PSSnapinHelp (Get-PSSnapin Pscx).ModuleName | Set-Content Output\MergedHelp.xml 
Convert-Xml Output\MergedHelp.xml -xslt Transformations\Maml.xslt | Set-Content .\Pscx.dll-Help.xml -Encoding Unicode

$MergedXml = [Xml](Get-Content Output\MergedHelp.xml)

$ReadmeTxt = $MergedXml.Cmdlets.Cmdlet |% {

	"    $($_.Verb)-$($_.Noun)"
	
	$_.DetailedDescription.Trim() | WrapText
	
	""
} 

Set-Content .\about_Pscx.help.txt $ReadmeTxt -Encoding Utf8